package com.cqgc.dao;

import com.cqgc.domain.Harvest;
import com.cqgc.domain.PageHelper;
import com.cqgc.domain.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface HarvestDao {
    @Select("select * from harvest where state = 1 limit #{currentPage},#{pageSize}")
    List<Harvest> findAll(PageHelper pagePelper);

    @Select("select * from harvest where state = 1 or state = 2")
    List<Harvest> findAllHarvest();

    @Select("select * from harvest where hid = #{hid}")
    Harvest findHarvestByHid(int hid);

    @Update("update harvest set hname = #{hname} , lan_number = #{lanNumber} , er_number = #{erNumber} , yvjing_number = #{yvjingNumber} , outline_number = #{outlineNumber} " +
            "where hid = #{hid}")
    int editHarvest(Harvest harvest);

    @Insert("insert into harvest values(null,#{hname},#{lanNumber},#{erNumber},#{yvjingNumber},#{outlineNumber},1)")
    int addHarvest(Harvest harvest);

    @Update("update harvest set state = 0 where hid = #{hid}")
    int deleteHarvest(Harvest harvest);

    @Update("update harvest set state = 2 where hid = #{hid}")
    int banHarvest(Harvest harvest);
}
